﻿/*
 * Copyright (C) 2012, Jesus Requejo <jesus.requejo@gmail.com> 
 * Licensed under Microsoft Public License (Ms-PL)
 * http://www.microsoft.com/en-us/openness/licenses.aspx#MPL
*/

namespace WindowsService {

   using System;
   using System.ComponentModel;
   using System.Configuration.Install;
   using System.ServiceProcess;
   
   [RunInstaller(true)]
   public partial class ProjectInstaller : Installer {
      public ProjectInstaller() {
         InitializeComponent();
      }

      private void StartServiceAfterInstall() {
         using (var serviceController = new ServiceController(this.loaderServiceInstaller.ServiceName, Environment.MachineName)) {
            serviceController.Start();
         }
      }

      protected override void OnCommitted(System.Collections.IDictionary savedState) {
         base.OnCommitted(savedState);
         StartServiceAfterInstall();
      }
   }
}
